@extends('admin.layout.app')
@section('title', '用户管理')

@section('nav')
    @include('admin.layout.nav', ['title'=> ['系统管理','申请项目']])
@endsection

@section('content')
    <div class="box box-primary" style="min-height: 300px;">
        <div class="box-header with-border">
            <h3 class="box-title">申请项目</h3>
        </div>
        <!-- /.box-header -->
        <form class="" action="" method="post" id="add-form" autocomplete="off">
            {{ csrf_field() }}
            <div class="box-body">
                <div class="form-group">
                    <label for="username">项目名称：</label>
                    <input type="text" class="form-control" name="name" value="{{old('username')}}"  placeholder="请输入">
                    @if($errors->has('name'))
                        <label class="control-label error" for="inputError1">{{$errors->first('name')}}</label>
                    @endif
                </div>
                <div class="form-group">
                    <label for="reason">申请理由：</label>
                    <input type="text" class="form-control" name="reason" value="{{old('reason')}}"  placeholder="请输入">
                    @if($errors->has('reason'))
                        <label class="control-label error" for="inputError1">{{$errors->first('reason')}}</label>
                    @endif
                </div>
                <div class="form-group">
                    <label for="money">项目金额：</label>
                    <input type="text" class="form-control" name="money" value="{{old('money')}}"  placeholder="请输入">
                    @if($errors->has('money'))
                        <label class="control-label error" for="inputError1">{{$errors->first('money')}}</label>
                    @endif
                </div>
                <div class="form-group">
                    <label for="first_party">项目甲方：</label>
                    <input type="text" class="form-control" name="first_party" value="{{old('first_party')}}"  placeholder="请输入">
                    @if($errors->has('first_party'))
                        <label class="control-label error" for="inputError1">{{$errors->first('first_party')}}</label>
                    @endif
                </div>
            </div>
            <!-- /.box-body -->

            <div class="box-footer">
                <input type="submit" class="btn btn-primary" value="提交">
                <a class="btn btn-default pull-right" href="javascript:window.history.back();">返回</a>
            </div>
        </form>

    </div>
@endsection

@section('style')
    <link rel="stylesheet" href="/lib/jquery.validation/1.14.0/validation.css">
    <link rel="stylesheet" href="/AdminLTE-2.4.2/bower_components/select2/select2.min.css">
    <style>

    </style>
@endsection

@section('js')
    <script type="text/javascript" src="/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript" src="/AdminLTE-2.4.2/bower_components/select2/select2.full.min.js"></script>
    <script >
        $(function(){
            $('#assign-roles').select2();
            $("#add-form").validate({
                rules: {
                    name: {
                        required: true,
                        minlength: 2,
                        maxlength: 100
                    },
                    reason: {
                        required: true,
                        maxlength: 200
                    },
                    money: {
                        required: true,
                        maxlength: 5
                    },
                    first_party: {
                        required: true,
                        maxlength: 100
                    }
                },
                messages: {
                    name: {
                        required: "请输入项目名",
                        minlength: "项目名必需由两个字母组成",
                        maxlength: '项目名不能超过100个字符'
                    },
                    reason: {
                        required: "请输入",
                        maxlength: '不能超过200个字符'
                    },
                    money: {
                        required: "请输入",
                        maxlength: '长度不超过5'
                    },
                    first_party: {
                        required: "请输入",
                        maxlength: '长度不超过100'
                    },

                },
                errorPlacement: function(error, element) {
                    error.appendTo(element.parent());
                }
            })
        })
    </script>
@endsection